<?php
namespace User\Controller;
use Think\Controller;
use Think\Model;

class MiniCityController extends Controller
{
	public function check()
	{
		$result = array( 'parent' => null, 'sons' => '' );
		$code = I( "get.code", -1, "" );
		$result['parent'] = D( 'region' )->where( "id = %d", array( $code ) )->find();
		$result['sons'] = D( 'region' )->where( "parentid = %d", array( $code ) )->select();

		$this->ajaxReturn( $result );
	}


    public function checks()
    {
        $result = array();
        $codes = I( "post.codes", array(), "" );
        if( !count( $codes ) ){
            return $this->ajaxReturn( $result );
        }

        $condition['id'] = array( 'in', $codes );
        $result = D( "region" )->where( $condition )->select();

        $this->ajaxReturn( $result );
    }
}
